package chances.epg.ui.taglib.html;

import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

import javax.servlet.jsp.JspException;

import chances.epg.ui.taglib.model.Rect;

public class ThumTag extends TextTag {

	private static final long serialVersionUID = -3907164904005837742L;

	private String title;
	private String poster;
	private String icon;
	private String tips;

	private String titleRectSytle;
	private String posterRectStyle;
	private String iconRectStyle;
	private String tipsRectStyle;

	private Rect titleRect;
	private Rect posterRect;
	private Rect iconRect;
	private Rect tipsRect;

	private String titleClass;
	private String iconClass;
	private String posterClass;
	private String tipsClass;

	@Override
	public void release() {
		this.titleClass = null;
		this.iconClass = null;
		this.posterClass = null;
		this.tipsClass = null;
		this.titleRect = null;
		this.iconRect = null;
		this.tipsRect = null;
		this.iconRect = null;
		this.titleRectSytle = null;
		this.iconRectStyle = null;
		this.tipsRectStyle = null;
		this.posterRectStyle = null;
		this.title = null;
		this.poster = null;
		this.icon = null;
		this.tips = null;
		super.release();
	}

	@Override
	public void doAfterStart() throws JspException {
		this.vm = "thum";
		super.doAfterStart();
		List<Rect> rects = Arrays.asList(Rect.parseStyle(posterRectStyle), Rect.parseStyle(titleRectSytle),
				Rect.parseStyle(iconRectStyle), Rect.parseStyle(tipsRectStyle));

		rects = rects.stream().map(s -> {
			return this.getChildRect(s);
		}).collect(Collectors.toList());

		posterRect = rects.get(0);
		titleRect = rects.get(1);
		iconRect = rects.get(2);
		tipsRect = rects.get(3);

	}

	public Rect getTipsRect() {
		return tipsRect;
	}

	public void setTipsRect(Rect tipsRect) {
		this.tipsRect = tipsRect;
	}

	public Rect getPosterRect() {
		return posterRect;
	}

	public Rect getIconRect() {
		return iconRect;
	}

	public void setPosterRect(Rect posterRect) {
		this.posterRect = posterRect;
	}

	public void setIconRect(Rect iconRect) {
		this.iconRect = iconRect;
	}

	public String getTitle() {
		return title;
	}

	public String getPoster() {
		return poster;
	}

	public String getIcon() {
		return icon;
	}

	public String getTips() {
		return tips;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public void setPoster(String poster) {
		this.poster = poster;
	}

	public void setIcon(String icon) {
		this.icon = icon;
	}

	public void setTips(String tips) {
		this.tips = tips;
	}

	public String getTitleRectSytle() {
		return titleRectSytle;
	}

	public String getPosterRectStyle() {
		return posterRectStyle;
	}

	public String getTipsRectStyle() {
		return tipsRectStyle;
	}

	public void setTitleRectSytle(String titleRectSytle) {
		this.titleRectSytle = titleRectSytle;
	}

	public String getIconRectStyle() {
		return iconRectStyle;
	}

	public void setIconRectStyle(String iconRectStyle) {
		this.iconRectStyle = iconRectStyle;
	}

	public String getTitleClass() {
		return titleClass;
	}

	public String getIconClass() {
		return iconClass;
	}

	public String getPosterClass() {
		return posterClass;
	}

	public String getTipsClass() {
		return tipsClass;
	}

	public void setTitleClass(String titleClass) {
		this.titleClass = titleClass;
	}

	public void setIconClass(String iconClass) {
		this.iconClass = iconClass;
	}

	public void setPosterClass(String posterClass) {
		this.posterClass = posterClass;
	}

	public void setTipsClass(String tipsClass) {
		this.tipsClass = tipsClass;
	}

	public void setPosterRectStyle(String posterRectStyle) {
		this.posterRectStyle = posterRectStyle;
	}

	public void setTipsRectStyle(String tipsRectStyle) {
		this.tipsRectStyle = tipsRectStyle;
	}

	public Rect getTitleRect() {
		return titleRect;
	}

	public void setTitleRect(Rect titleRect) {
		this.titleRect = titleRect;
	}

}
